package com.zy.test.rabbitmq.producer;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Console;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * rabbitmq 生产者
 *
 * @Author jhr
 * @Date 2023/6/1
 */
@Component
public class Producer {
    @Resource
    RabbitTemplate rabbitTemplate;

    public void produce(){
        String message = DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN) +"beijing";
        Console.log("生产者生产消息====="+message);
        rabbitTemplate.convertAndSend("rabbitmq_queue",message);
    }
}
